/*
 * Copyright 2010 Marcin Czeczko.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.czeczek.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;

import org.joda.time.LocalDate;
import org.joda.time.LocalTime;


public class Quote implements Serializable {
    /**
	 * 
	 */
	private static final long serialVersionUID = 6343553949167143948L;
	
    private long quoteId;
	private String symbol;
	private LocalDate date;
	private LocalTime time;
    private BigDecimal openPrice;
    private BigDecimal highPrice;
    private BigDecimal lowPrice;
    private BigDecimal closePrice;
    private BigDecimal volume;
    private BigInteger openInterest;

    public Quote(Quote quote) {
    	this.quoteId = quote.quoteId;
		this.symbol = quote.symbol;
		this.date = quote.date;
		this.time = quote.time;
		this.openPrice = quote.openPrice;
		this.highPrice = quote.highPrice;
		this.lowPrice = quote.lowPrice;
		this.closePrice = quote.closePrice;
		this.volume = quote.volume;
		this.openInterest = quote.openInterest;
    }
    

    public Quote() {
	}
    
    public long getQuoteId() {
    	return quoteId;
    }

	public String getSymbol() {
		return symbol;
	}


	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}


	public LocalDate getDate() {
		return date;
	}


	public void setDate(LocalDate date) {
		this.date = date;
	}


	public LocalTime getTime() {
		return time;
	}


	public void setTime(LocalTime time) {
		this.time = time;
	}


	public BigDecimal getOpenPrice() {
		return openPrice;
	}


	public void setOpenPrice(BigDecimal openPrice) {
		this.openPrice = openPrice;
	}


	public BigDecimal getHighPrice() {
		return highPrice;
	}


	public void setHighPrice(BigDecimal highPrice) {
		this.highPrice = highPrice;
	}


	public BigDecimal getLowPrice() {
		return lowPrice;
	}


	public void setLowPrice(BigDecimal lowPrice) {
		this.lowPrice = lowPrice;
	}


	public BigDecimal getClosePrice() {
		return closePrice;
	}


	public void setClosePrice(BigDecimal closePrice) {
		this.closePrice = closePrice;
	}


	public BigDecimal getVolume() {
		return volume;
	}


	public void setVolume(BigDecimal volume) {
		this.volume = volume;
	}


	public BigInteger getOpenInterest() {
		return openInterest;
	}


	public void setOpenInterest(BigInteger openInterest) {
		this.openInterest = openInterest;
	}
	
	public void setQuoteId(long id) {
		this.quoteId = id;
	}


	@Override
	public String toString() {
		return "Trade [quoteId=" + quoteId + ", symbol=" + symbol + ", date="
				+ date + ", time=" + time + ", openPrice=" + openPrice
				+ ", highPrice=" + highPrice + ", lowPrice=" + lowPrice
				+ ", closePrice=" + closePrice + ", volume=" + volume
				+ ", openInterest=" + openInterest + "]";
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((closePrice == null) ? 0 : closePrice.hashCode());
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		result = prime * result
				+ ((highPrice == null) ? 0 : highPrice.hashCode());
		result = prime * result
				+ ((lowPrice == null) ? 0 : lowPrice.hashCode());
		result = prime * result
				+ ((openInterest == null) ? 0 : openInterest.hashCode());
		result = prime * result
				+ ((openPrice == null) ? 0 : openPrice.hashCode());
		result = prime * result + (int) (quoteId ^ (quoteId >>> 32));
		result = prime * result + ((symbol == null) ? 0 : symbol.hashCode());
		result = prime * result + ((time == null) ? 0 : time.hashCode());
		result = prime * result + ((volume == null) ? 0 : volume.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Quote other = (Quote) obj;
		if (closePrice == null) {
			if (other.closePrice != null)
				return false;
		} else if (!closePrice.equals(other.closePrice))
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (highPrice == null) {
			if (other.highPrice != null)
				return false;
		} else if (!highPrice.equals(other.highPrice))
			return false;
		if (lowPrice == null) {
			if (other.lowPrice != null)
				return false;
		} else if (!lowPrice.equals(other.lowPrice))
			return false;
		if (openInterest == null) {
			if (other.openInterest != null)
				return false;
		} else if (!openInterest.equals(other.openInterest))
			return false;
		if (openPrice == null) {
			if (other.openPrice != null)
				return false;
		} else if (!openPrice.equals(other.openPrice))
			return false;
		if (quoteId != other.quoteId)
			return false;
		if (symbol == null) {
			if (other.symbol != null)
				return false;
		} else if (!symbol.equals(other.symbol))
			return false;
		if (time == null) {
			if (other.time != null)
				return false;
		} else if (!time.equals(other.time))
			return false;
		if (volume == null) {
			if (other.volume != null)
				return false;
		} else if (!volume.equals(other.volume))
			return false;
		return true;
	}

 }
